<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="./static/element-plus/index.css" />
    <script src="./static/js/vue.global.js"></script>
    <script src="./static/element-plus/index.full.js"></script>
    <title>登录</title>
    <style>
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            background-color: #f5f5f5;
        }
    </style>
</head>

<body>
    <div id="login">
        <el-container>
            <el-header>
                <h1>登录</h1>
            </el-header>
            <el-main>
                <el-form :model="loginForm" label-width="80px">
                    <el-form-item label="用户名">
                        <el-input v-model="loginForm.username"></el-input>
                    </el-form-item>
                    <el-form-item label="密码">
                        <el-input type="password" v-model="loginForm.password"></el-input>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="submitLogin">登录</el-button>
                        <el-button type="primary" @click="submitRegister">注册</el-button>
                    </el-form-item>
                </el-form>
            </el-main>
        </el-container>
    </div>
    <script>
        const LoginApp = {
            data() {
                return {
                    loginForm: {
                        username: '',
                        password: ''
                    }
                };
            },
            methods: {
                submitLogin() {
                    if (this.loginForm.username && this.loginForm.password) {
                    
                        window.location.href = "./index.html"; 
                    } else {
                        alert("用户名和密码不能为空！");
                    }
                },
                submitRegister() {
                    window.location.href = "/Register.html"; 
                }
            }
        };
        Vue.createApp(LoginApp).use(ElementPlus).mount("#login");
    </script>
</body>

</html>